<!DOCTYPE html>
<!--
 * Copyright (c) 2010 The Chromium Authors. All rights reserved.  Use of this
 * source code is governed by a BSD-style license that can be found in the
 * LICENSE file.
 *
 * Author: Eric Bidelman <ericbidelman@chromium.org>
-->
<html>
  <head>
    <title>Options</title>
    <script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
  </head>
  <body onload="initUI();">
    <p><button id="revoke" onclick="logout();">Revoke your OAuth token</button></p>
    <p>Refresh rate (seconds): <input id="refresh_rate" value="300"></p>
    <script type="text/javascript">
      var bgPage = chrome.extension.getBackgroundPage();

      $('#refresh_rate').change(function() {
        localStorage.refreshRate = $(this).val();
        bgPage.refreshRate = localStorage.refreshRate;
        bgPage.pollIntervalMin =  bgPage.refreshRate * 1000;
      });

      function logout() {
        bgPage.logout();
        $('#revoke').get(0).disabled = true;
      }

      function initUI() {
        if (!bgPage.oauth.hasToken()) {
          $('#revoke').get(0).disabled = true;
        }

        if (localStorage.refreshRate) {
          $('#refresh_rate').val(localStorage.refreshRate);
        } else {
           $('#refresh_rate').val(bgPage.refreshRate);
        }
      }
    </script>
  </body>
</html>
